package com.txooo.library.utils;

/**
 * Created by wwb on 2017/8/28.
 * 防止按钮重复点击
 * 用法：
 * if (!NoDoubleClickUtils.isDoubleClick())
 * {
 * 事件响应方法
 * }
 */

public class NoDoubleClickUtils {

    private static long lastClickTime;
    private final static int SPACE_TIME = 500;

    public static void initLastClickTime() {
        lastClickTime = 0;
    }

    public synchronized static boolean isDoubleClick() {
        long currentTime = System.currentTimeMillis();
        boolean isClick2;
        if (currentTime - lastClickTime > SPACE_TIME) {
            isClick2 = false;
        } else {
            isClick2 = true;
        }
        lastClickTime = currentTime;
        return isClick2;
    }
}
